{extend name="base"/}
{block name="main"}
<div class="Hui-article">
    <article class="cl pd-20">
        <div class="n_tab_line">
            <a href="" class="n_tab_list">等级列表</a>
            <div class="l n_tab_add" style="width: auto">
                <button type="button"  class="btn btn-search radius"
                        onclick="level_add('添加会员等级','{:url(\'user/add_level\')}','650px','500px')">
                    <i class="Hui-iconfont">&#xe600;</i> 添加等级
                </button>
            </div>
        </div>
        <table class="table table-border table-bordered table-bg">
            <thead>
            <tr class="text-c">
                <th>会员等级</th>
                <th>等级名称</th>
                <th>累计积分</th>
                <th>享受折扣</th>
                <!--<th>积分抵扣比例</th>-->
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="list" id="vo"}
            <tr class="text-c">
                <td>{$vo['level']}</td>
                <td>{$vo['level_name']}</td>
                <td>{$vo['hierarchy']}</td>
                <th>{$vo['rebate']|default="10"}折</th>
                <!--<th>{$vo['deduction']|default="0"}%</th>-->
                <td>
                    <a title="编辑" href="javascript:;" onclick="level_edit('编辑会员等级','{:url(\'user/edit_level\')}&id={$vo.id}','650px','500px')" class="ml-5" style="text-decoration:none">编辑</a>
                    <a title="删除" href="javascript:;" onclick="level_del('{$vo.id}')" class="ml-5" style="text-decoration:none">删除</a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </article>
    <div class="n_page_no">
        {$list->render()}
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    function level_add(title, url, w, h) {
        layer.open({
            type: 2,
            area: [w, h],
            fix: false, //不固定
            maxmin: true,
            shade: 0.4,
            title: title,
            content: url,
            scrollbar: false
        });
    }
    function level_edit(title, url, w, h) {
        layer.open({
            type: 2,
            area: [w, h],
            fix: false, //不固定
            maxmin: true,
            shade: 0.4,
            title: title,
            content: url,
            scrollbar: false
        });
    }
    function level_del(id) {
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type : "post",
                url : "{:url('user/level_del')}",
                data: {id: id},
                success : function(data) {
                    if(data['code']>0 ){
                        layer.msg('删除成功',{icon:1,time:1000},function () {
                            location.reload();
                        });
                    }else{
                        layer.msg(data['data'],{icon:5,time:1000});
                    }
                }
            });
        });
    }
</script>
{/block}